import { debounce } from '@/utils/public'
export default {
	props: {
		chartData: {
			type: Array,
			default: () => {
				return []
			},
		},
	},
	data() {
		return {
			chart: null,
		}
	},
	watch: {
		chartData: {
			// immediate: true,
			deep: true,
			handler: function(newValue, oldValue) {
				this.initChart()
			},
		},
	},
	mounted() {
		window.addEventListener('resize', debounce(this.resizeChart, 200), false)
	},
	destroyed() {
		window.removeEventListener('resize', this.resizeChart)
	},
	methods: {
		resizeChart() {
			if (this.chart) {
				this.chart.resize()
			}
		},
	},
}
